/*
*	ID : pallab81
* 	PROG : 662
* 	LANG : C++
* 	2012-06-14-22.33.21 Thursday
*
* 	"I have not failed, I have just found 10000 ways that won't work.
*/

#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;


#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )
#define fo(i1,ed) foR( i1 , 0 , ed )
#define foE(i1,st,ed) foR( i1, st, ed+1 )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")

template<class T1>
inline void debug(T1 _x) {
    cout<<_x<<'\n';
}
template<class T1, class T2>
inline void debug(T1 _x,T2 _y) {
    cout<<_x<<' '<<_y<<'\n';
}
template<class T1, class T2, class T3>
inline void debug(T1 _x,T2 _y,T3 _z) {
    cout<<_x<<' '<<_y<<' '<<_z<<'\n';
}
template<class T1, class T2, class T3, class T4>
inline void debug(T1 _x,T2 _y,T3 _z,T4 _zz) {
    cout<<_x<<' '<<_y<<' '<<_z<<' '<<_zz<<'\n';
}
template< class T1>
inline void debug(T1 _array,int _size) {
    cout<<"[";
    for (int i=0; i<_size; ++i) {
        cout<<' '<<_array[i];
    }
    puts(" ]");
}
inline bool CI(int &_x) {
    return scanf("%d",&_x)==1;
}
inline bool CI(int &_x, int &_y) {
    return CI(_x)&&CI(_y) ;
}
inline bool CI(int &_x, int &_y, int &_z) {
    return CI(_x)&&CI(_y)&&CI(_z) ;
}
inline bool CI(int &_x, int &_y, int &_z, int &_zz) {
    return CI(_x)&&CI(_y)&&CI(_z)&&CI(_zz) ;
}
inline void wait( double seconds ) {
    double endtime = clock()+( seconds* CLOCKS_PER_SEC );
    while( clock() < endtime ) {
        ;
    }
}
namespace In {
int kase=1;
int N,K;
int vi[201];
inline void read() {
    fo(i,N)
    CI( vi[i] );
}
}

namespace algo {
const int inf=1023456789;
int dp[201][201][31];
int go(int at,int from, int need) {

    if(at>=In::N) {
        if( from>=In::N ) {
            if( need==0 ) {
                return 0;
            }
        }
        return inf;
    }


    int& best=dp[at][from][need];
    if(best!=-1)return best;

    best=inf;
    int d=go(at+1,from,need);
    best=min(best,d);


    d=0;
    if(need>0) {
        //build a depo here
        for(int i=from; i<In::N; ++i) {
            d+= abs(In::vi[i]-In::vi[at]);
            if(i>=at) {
                int e=d+go(i+1, i+1, need-1);
                best=min(best,e);
            }
        }
    }

    return best;
}
void bk(int at, int from, int need, int curCost) {
    if(at>=In::N )return ;

    if( curCost == go(at+1, from, need) ) {
        bk(at+1, from, need, curCost);
    } else {
        int d=0;
        //build a depo here
        for(int i=from; i<In::N; ++i) {
            d+= abs(In::vi[i]-In::vi[at]);
            if(i>=at) {
                if(curCost==d+go(i+1, i+1, need-1)) {
                    if(from+1!=i+1){
                        printf("Depot %d at restaurant %d serves restaurants %d to %d\n", (In::K-need+1),at+1,from+1,i+1 );
                    }
                    else{
                        printf("Depot %d at restaurant %d serves restaurant %d\n", (In::K-need+1),at+1,from+1 );
                    }
                    bk(i+1,i+1,need-1, curCost-d);
                }
            }
        }

    }

}
}
inline void Solve() {
    In::read();
    printf("Chain %d\n",In::kase);
    SET(algo::dp,-1);
    int ret=algo::go(0,0,In::K);
    algo::bk(0,0,In::K,ret);
    printf("Total distance sum = %d\n\n",ret);

}
#define FILE
//#define showCase
int main() {
#ifdef FILE
    freopen("/home/xerxes/Documents/662/in","rt",stdin);
#endif

    while( scanf("%d %d",&In::N,&In::K)==2 ) {
        if(!In::N&&!In::K)break;
        Solve();
        In::kase++;
    }

    return 0;
}
